package com.module.aichat.ui.widget.inputview

import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.common.base.app.extras.dpDimenPx
import com.common.base.app.extras.setOnClickListener
import com.module.aichat.R


/**
 *
 * 作者：sosou
 *
 * 版本：1.0
 *
 * 创建日期：2025/6/30
 *
 * 描述：
 *
 * 修订历史：
 *
 */
class AiSbListAdapter :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.aichat_item_ai_sb_list_view) {


    private var listener: OnAiSbListAdapterListener? = null

    override fun convert(holder: BaseViewHolder, item: String) {
        holder.setText(R.id.tvTypeStr, item)
        holder.getView<TextView>(R.id.tvTypeStr).setOnClickListener(onClick = object :
            View.OnClickListener {
            override fun onClick(p0: View?) {
                listener?.onAiSbListAdapterStr(item)
            }

        })
//        holder.getView<TextView>(R.id.tvTypeStr).apply {
//            // 判断是否为最后一条数据
//            val isLastItem = holder.layoutPosition == data.size - 1
//            if (!isLastItem) {
//                // 不是最后一条数据，添加右边外边距
//                val layoutParams = this.layoutParams as ViewGroup.MarginLayoutParams
//                layoutParams.leftMargin = dpDimenPx(R.dimen.dp_8).toInt()
//                layoutParams.rightMargin = dpDimenPx(R.dimen.dp_8).toInt()
//                this.layoutParams = layoutParams
//            } else {
//                // 是最后一条数据，移除右边外边距
//                val layoutParams = this.layoutParams as ViewGroup.MarginLayoutParams
//                layoutParams.rightMargin = dpDimenPx(R.dimen.dp_8).toInt()
//                this.layoutParams = layoutParams
//            }
//        }
    }



    /**
     * @param listener
     */
    fun setListener(listener: OnAiSbListAdapterListener?) {
        this.listener = listener
    }

    /**
     *
     */
    interface OnAiSbListAdapterListener {
        fun onAiSbListAdapterStr(mStr:String)
    }
}